
var unitId="";
var ids=utils.getParameter("ids");
$(function () {
    //var ids = getParameter(ids);
    //加载菜单树
    $.get("../custombaseinfo/getTree", function(r){
       var  ztree = $.fn.zTree.init($("#menuTreeScreen"), setting, r.list);
        //展开所有节点
        ztree.expandAll(true);
    });
})
var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "unitId",
            pIdKey: "unitCode",
            rootPId: null
        },
        key: {
            url:"nourl"
        }
    },
    check:{
        enable:false,//是否显示勾选框
        nocheckInherit:true
    },
    callback:{
       // beforeClick: getCurrentNode
        onClick : zTreeOnClick
    }
};
function zTreeOnClick(e, treeId, node){
    unitId=node.unitId;
};
$("#submit").click(function(){
	if(unitId==""){
        alert("请选择派遣单位！");
        return;
	}
    var params = {
        unitId:unitId,
        ids:ids
    }
    $.ajax({
        type: "POST",
        url: "../empbaseinfo/insertdispatch",
        contentType: "application/json",
        data: JSON.stringify(params),
        dataType:"json",
        async:false,
        cache:false,
        success: function(r){
            if(r.code === 0){
                alert('操作成功', function(index){
                    utils.closeCurrentPage();
                });
            }else{
                alert(r.msg);
            }
        }
    });
});
$("#close").click(function(){
    utils.closeCurrentPage();
});